//
// Created by 62607 on 25-8-6.
#include <bits/stdc++.h>
#include <iostream>
#include <ostream>
using namespace std;
int t[100000];
int n;

int lowbit(int n) {
    return n & (-n);
    //return n&(~n+1)
}

//求前缀和
int ask(int n) {
    int sum = 0;
    while (n != 0) {
        sum += t[n];
        n -= lowbit(n);
    }
    return sum;
}

void add(int x, int v) {
    while (x <= n) {
        t[x] += v;
        x += lowbit(x);
    }
}

int main() {
    cin>>n;
    for (int i = 1; i <= n; i++) {
        int v;
        cin >> v;
        add(i, v);
    }
    int q;
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b;
        cout << ask(b) - ask(a - 1) << endl;
    }
    return 0;
}
